package mts.constants;

public enum StatusType {
	SPOOLING((byte)0) {
		@Override
		public String toString() {
			return "IDLE";
		}
	},
	
	MOVING((byte)1) {
		@Override
		public String toString() {
			return "MOVE";
		}
	},
	OPENING((byte)2) {
		@Override
		public String toString() {
			return "OPEN";
		}
	},
	CLOSING((byte)3) {
		@Override
		public String toString() {
			return "CLOSE";
		}
	},
	STOPPED((byte)4) {
		@Override
		public String toString() {
			return "STOP";
		}
	},
	ERROR((byte)-1) {
		@Override
		public String toString() {
			return "ERROR";
		}
	};
	
	byte val;
	
	public byte getByteValue() {
		return val;
	}
	
	private StatusType(byte val) {
		this.val = val;
	}
	
	public static StatusType valueOf(byte val) {
		for (StatusType status: StatusType.values()) {
			if (status.val == val ) {
				return status;
			}
		}
		
		throw new RuntimeException("Invalid CarStatus - " + val);
	}
}
